<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Editorial extends CI_Controller {
	function __construct()
	{
		parent::__construct();
		$this->load->helper('url');
		$this->load->model('process_data');
		$this->load->model('adminsessions');

		if(!$this->adminsessions->isLogedIn()){
			redirect(base_url()."admin/home/login");
		}
	}
	public function index()
	{
		$data['editorials'] = $this->process_data->getEditorialMembers();
		$this->load->view('admin/editorial/index', $data);
	}
	public function addMember()
	{
		if(isset($_POST['addMemberPostData']))	{
			$this->process_data->addEditorialMembers();
			redirect(base_url().'admin/editorial');
		}else{
			if(isset($_GET['id'])){
				$data['editorials'] = $this->process_data->getEditorialMembers($_GET['id']);
				$this->load->view('admin/editorial/addmember', $data);
			}else {
				redirect(base_url().'admin/editorial');
			}
		}
	}
}